<template>
  <div v-show="id">
    <h3>电话医生设置</h3>
      <p>服务区域：{{ptPhoneDoctor.cityCodesValue}}</p>
      <p>服务次数：{{ptPhoneDoctor.serverTimesValue}}</p>
      <p>单次时长：{{ptPhoneDoctor.singleDurationValue}}</p>
      <p>自费购买：{{ptPhoneDoctor.selfPay}}</p>
      <p>等待期：{{ptPhoneDoctor.waitMonthsValue}}</p>
  </div>
</template>

<script>
export default {
  name: 'youDoctor',
  props: {
    id: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      ptPhoneDoctor: {}
    }
  },
  methods: {
    getData () {
      this.axios.get(`/goods/phoneDoctor/${this.id}`).then((res) => {
        const code = Number(res.data.code)
        if (code === 200) {
          this.ptPhoneDoctor = res.data.data
          this.ptPhoneDoctor.cityCodesValue = this.ptPhoneDoctor.cityCodes == '-1' ? '全国' : this.ptPhoneDoctor.cityCodes
          this.ptPhoneDoctor.serverTimesValue = this.ptPhoneDoctor.serverTimes == '-1' ? '不限' : (this.ptPhoneDoctor.serverTimes + '次')
          this.ptPhoneDoctor.singleDurationValue = this.ptPhoneDoctor.singleDuration == '-1' ? '不限' : (this.ptPhoneDoctor.singleDuration + '分钟')
          this.ptPhoneDoctor.selfPayValue = this.ptPhoneDoctor.selfPay == '-1' ? '不允许' : (this.ptPhoneDoctor.selfPay + '元')
          this.ptPhoneDoctor.waitMonthsValue = this.ptPhoneDoctor.waitMonths == '-1' ? '无' : (this.ptPhoneDoctor.waitMonths + '天')
        } else {
          this.$message(this.mes.busy)
        }
      }).catch((err) => {
        console.log(err)
        this.$message(this.mes.busy)
      })
    }
  },
  watch: {
    id() {
      this.getData()
    }
  }
}
</script>

<style>

</style>
